<%@ page import="com.demo.main.utils.Result" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh-CN">
<head>
    <title>登录</title>
    <link rel="stylesheet" href="/resources/css/bootstrap.min.css">
    <link rel="stylesheet" href="/resources/css/index.css">
    <script>
        window.onload = function() {
            document.getElementsByName("username")[0].value = "user"; // 设置默认的用户名
            document.getElementsByName("password")[0].value = "123"; // 设置默认的密码
        };
    </script>

    <style>
        .container-fluid.login-container {
            display: flex;

            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .login-box {
            background-color: #fff;
            width: 400px;
            padding: 20px;
        }

        .login-box-title {
            text-align: center;
            margin-bottom: 20px;
        }

        .login-box-identity {
            list-style-type: none;
            display: flex;
            justify-content: space-between;
            padding: 0;
            margin-bottom: 20px;
        }

        .login-box-identity li {
            margin-right: 18px;
        }

        .login-box-identity label {
            margin-left: 5px;
        }

        .login-box-form {
            margin-top: 20px;
        }

        .form-group.row {
            margin-bottom: 15px;
        }

        .form-group.row label {
            text-align: right;
            padding-right: 10px;
        }

        .form-control {
            width: 100%;
            padding: 10px;
        }

        .btn-primary {
            background-color: #555;
            color: #fff;
            border: none;
            padding: 10px 20px;
            cursor: pointer;
        }


    </style>
</head>
<body>
<%
    Result<String> result = (Result) request.getAttribute("data");
%>
<script lang="javascript">
    const e =
    <%=result == null ? false : result.getCode()%>
    if (e) {
        alert("<%=(result == null) ? "" : result.getData()%>")
    }
</script>
<div class="container-fluid login-container">
    <div class="login-box">
        <h3 class="login-box-title">图书管理系统</h3>
        <form action="/login" method="post" class="clearfix">
            <ul class="login-box-identity">
                <li style="margin-right: 18px">
                    <input type="radio" name="identity" checked value="user"
                           id="identity-user">
                    <label for="identity-user">用户</label>
                </li>
                <li>
                    <input type="radio" name="identity" value="admin"
                           id="identity-admin">
                    <label for="identity-admin">管理员</label>
                </li>
            </ul>
            <div class="login-box-form">
                <div class="form-group row">
                    <label class="col-3">用户名</label>
                    <input type="text" class="form-control col-8" name="username">
                </div>
                <div class="form-group row">
                    <label class="col-3">密码</label>
                    <input type="password" class="form-control col-8" name="password">
                </div>
                <button type="submit" class="btn btn-primary" style="margin-top: 20px">登录</button>
                <a href="/login?method=register-page" class="btn btn-primary" style="margin-top: 20px;margin-left: 160px">用户注册</a>
            </div>
        </form>
    </div>
</div>

</body>
</html>
